home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
cgraphix
/
cpolyax.c
< prev
next >
Wrap
Text File
|
1986-05-28
|
905b
|
60 lines
/* «RM120»«PL99999»«TS4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76» */
#include <stdio.h>
#define EXTERN extern
#include <typedef.h>
#define PI 3.14158928
extern double sin();
void GenerateFunction(a,b,n)
double *a, *b;
int n;
{
int i;
double delta;
delta = 2*PI/(n-1);
for (i = 0; i < n; i++) {
a[2 * i] = i*delta-PI;
a[2 * i + 1] = sin(a[i* 2]);
}
}
void PolygonDem()
{
int n;
PlotArray b,a;
char ch;
int x1,x2;
ClearScreen();
n = 30;
GenerateFunction(a,b,n);
DefineWindow(1,0,0,XMaxGlb,YMaxGlb);
DefineHeader(1,"SINE CURVE AS A POLYGON");
DefineWorld(1, -PI, -1., PI, 1.);
SelectWorld(1);
SelectWindow(1);
SetBackground(0);
SetHeaderOn();
DrawBorder();
DrawAxis(8,-8,0,0,0,0,0,0,FALSE);
DrawPolygon(a,1-1,n-1,0,0,0);
}
main()
{
InitGraphic();
PolygonDem();
inkey();
LeaveGraphic();
}